#ifndef POINT_H
#define POINT_H

#include <QPoint>
#include <QString>
namespace GeometryUtilities
{
  class Point : public QPointF
  {
    public:
      Point();
      Point(qreal x, qreal y);
      Point(const QPoint& qpt);
      Point(const QPointF& qpt);

      Point operator/(qreal scaler) const;
      Point operator*(qreal scaler) const;
      Point operator-(const Point& point) const;
      Point operator+(const Point& point) const;
      const Point& operator+=(const Point& point);
      const Point& operator-=(const Point& point);
      const Point& operator/=(qreal scaler);
      const Point& operator*=(qreal scaler);

      bool operator<(const Point& rhs) const;
      bool operator==(const Point& rhs) const;
      QString toString(const unsigned int precision=6) const;

      // All angles on circle use following values:
      //       .  90 .
      // 180/-180       0
      //       . -90  .

      // direction the point is located is from 0,0
      qreal angle(const bool clamp0to360=false) const;
      // bearing from p1 to p2.
      static qreal bearing(const Point &point1, const Point &point2);
      static qreal clampAngleTo360(const qreal value);
      static qreal clampAngleTo180(const qreal value);

      // Vector behaviors
      qreal magnitude() const;
      void normalize();
      Point normalized() const;
      qreal cross(const Point &point) const;
      qreal dot(const Point &point) const;
      qreal perpdot(const Point& point) const;
      qreal operator*(const Point &point) const; //dot-product
      // angle between 2 vectors(both methods return radians
      static qreal angle(const Point &point1, const Point &point2);
      static qreal signedangle(const Point& point1, const Point& point2);
  };
}

#endif // POINT_H
